/*******************************************************************************
 Configuration Information:
 Repository: Integrity Source
 Name      : $RCSfile: SPCM_MSPCS_ModMgr.c $
 Version   : $Revision: 1.5 $
 Author    : $Author: Zhengyi He (HeZ4) $
 Date      : $Date: 2019/06/13 09:26:08IST $
 Location  : $ProjectName: /Steering/Projects/Geely/CMA_DP/PR48756_LVS_ENG_APP_Geely_CMA_EPS_DP_SYS_HRoom_AP/30_Software/3040_Design/S2-Application/01-Development/V00-Mainline/04-Components/SteerPosnCtrlrManager/Source/project.pj $
********************************************************************************

   ZF Friedrichshafen AG owns the copyright in this document and associated
   documents and all rights are reserved.  These documents must
   not be used for any purpose other than that for which they
   are supplied and must not be copied in whole or in part or
   disclosed to others without prior written consent of ZF Friedrichshafen AG.
   Any copy of this drawing or document made by any method
   must also include a copy of this legend.

   (C) ZF Friedrichshafen AG 2018

*******************************************************************************/
/**************************************************************************************************\
 *** 
 *** Simulink model       : SPCM_MSPCS_ModMgr_tl
 *** TargetLink subsystem : SPCM_MSPCS_ModMgr_tl
 *** Codefile             : SPCM_MSPCS_ModMgr.c
 ***
 *** Generated by TargetLink, the dSPACE production quality code generator
 *** Model version: 1.65
 *** Generation date: 2019-06-13 11:36:03
 ***
 *** CODE GENERATOR OPTIONS:
 *** Code generation mode                     : AUTOSAR
 *** AUTOSAR version                          : 4.2.1
 *** Compiler                                 : <unknown>
 *** Target                                   : Generic
 *** ANSI-C compatible code                   : yes
 *** Code Optimization                        : enabled
 *** Constant style                           : decimal
 *** Clean code option                        : enabled
 *** Logging mode                             : Do not log anything
 *** Code Coverage                            : disabled
 *** Generate empty conditional branches      : disabled
 *** Loop unroll threshold                    : 5
 *** Shift mode                               : automatic
 *** Handle unscaled SF expr. with TL type    : enabled
 *** Assignment of conditions                 : AllBooleanOutputs 
 *** Scope reduction only to function level   : disabled
 *** Exploit ranges if not erasable           : disabled
 *** Exploit Compute Through Overflow         : never
 *** Linker sections                          : enabled
 *** Enable Assembler                         : disabled
 *** Variable name length                     : unlimited
 *** Use global bitfields                     : disabled
 *** Stateflow: use of bitfields              : enabled
 *** State activity encoding limit            : 8
 *** Omit zero inits in restart function      : disabled
 *** Share functions between TL subsystems    : disabled
 *** Generate 64bit functions                 : disabled
 *** Inlining Threshold                       : 6
 *** Line break limit                         : 100
 *** Target optimized boolean data type       : enabled
 *** Keep saturation elements                 : disabled
 *** Extended variable sharing                : disabled
 *** Extended lifetime optimization           : enabled
 *** Style definition file                    : C:\Program Files\dSPACE TargetLink 4.2\Matlab\Tl\Con
 ***                                            fig\codegen\cconfig.xml
 *** Root style sheet                         : C:\Program Files\dSPACE TargetLink 4.2\Matlab\Tl\XML
 ***                                            \CodeGen\Stylesheets\TL_CSourceCodeSS.xsl
 ***
 *** SUBSYS                   CORRESPONDING SIMULINK SUBSYSTEM
 *** SSPCM_MM_21              SPCM_MSPCS_ModMgr_tl
 *** SSPCM_MM_22              SPCM_MSPCS_ModMgr_tl/DocFunction
 *** SSPCM_MM_23              SPCM_MSPCS_ModMgr_tl/IncludeAppHeader
 *** SSPCM_MM_24              SPCM_MSPCS_ModMgr_tl/Logo
 *** SSPCM_MM_25              SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr
 *** SSPCM_MM_26              SPCM_MSPCS_ModMgr_tl/DocFunction/EmptySubsystem
 *** SSPCM_MM_27              SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColAbsPosnCheck
 *** SSPCM_MM_28              SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks
 *** SSPCM_MM_29              SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColAbsPosnCheck/ZFDivA_fabs
 *** SSPCM_MM_210             SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter
 *** SSPCM_MM_211             SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1
 *** SSPCM_MM_212             SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2
 *** SSPCM_MM_213             SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/ZFDivA_fabs
 *** 
 *** SUBSYS                   CORRESPONDING MODEL BLOCK (REFERENCED MODEL)
 *** 
 *** SF-NODE   CORRESPONDING STATEFLOW NODE                           DESCRIPTION
 *** CSPCM_MM_
 *** 20        SPCM_MSPCS_ModMgr_tl                                   
 *** CSPCM_MM_
 *** 21        SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine 
 *** CSPCM_MM_
 *** 22        SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine
 ***           .CLOSED                                                
 *** CSPCM_MM_
 *** 23        SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine
 ***           .READY                                                 
 *** CSPCM_MM_
 *** 24        SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine
 ***           .RAMPOUT                                               
 *** CSPCM_MM_
 *** 25        SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine
 ***           .ACTIVE                                                
 *** CSPCM_MM_
 *** 26        SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine
 ***           .HOLD                                                  
 *** 
 *** TargetLink version      : 4.2p2 from 27-Nov-2017
 *** Code generator version  : Build Id 4.2.0.33 from 2017-11-28 14:39:24

\**************************************************************************************************/

#ifndef SPCM_MSPCS_MODMGR_C
#define SPCM_MSPCS_MODMGR_C

/*----------------------------------------------------------------------------*\
  DEFINES (OPT)
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  INCLUDES
\*----------------------------------------------------------------------------*/

#include "SteerPosnCtrlrManagerSwc_Library.h"
#include "SPCM_MSPCS_ModMgr.h"
#include "Rte_SteerPosnCtrlrManagerSwc.h"

/*----------------------------------------------------------------------------*\
  ENUMS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  DEFINES
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  TYPEDEFS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  VARIABLES
\*----------------------------------------------------------------------------*/

/******************************************************************************\
   VC_STRUCT_InitAtDef: Used for global struct variables. Initialised at definition. Creates access 
   functions (get and set). | Width: N.A.
\******************************************************************************/
tSPCM_MSPCS_ModMgr var_SPCM_MSPCS_ModMgr = {
   0, /* SpcApplyingTq: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 1 */
   0, /* SpcArbActvnReq: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 100 */
   0, /* SpcCtrlrSt: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 10 */
   0, /* DrvrTakeOvDetd: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 1 */
   0 /* LatCtrlModCfmdSPC: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 14 */
};

/******************************************************************************\
   SFStaticGlobalInit: Default storage class for global static variables with initial value | Width:
    32
\******************************************************************************/
static sint32 CSPCM_MM_21_LatCtrlModCfmd_SPC = 0;
static sint32 CSPCM_MM_21_TargetControlMode_SPC = 0;
static uint32 CSPCM_MM_21_ramping_tmr = 0;
static tArbitrationState DD_CSPCM_MM_21_SpcArbActvnReq = 0; /* LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 99 */
static tSpcState DD_CSPCM_MM_21_SpcCtrlrSt = 0; /* LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 5 */

/******************************************************************************\
   SFStaticGlobalInit: Default storage class for global static variables with initial value | Width:
    8
\******************************************************************************/
static Boolean DD_CSPCM_MM_21_SpcApplyingTq = 0; /* LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 1 */

/******************************************************************************\
   SFStaticGlobalInit: Default storage class for global static variables with initial value | Width:
    N.A.
\******************************************************************************/
static struct tag_SIBFS_SpcStateMachine_SPCM_MM_2_tp SIBFS_SpcStateMachine_SPCM_MM_2 = {
   0, /* CSPCM_MM_22_CLOSED: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 1 */
   0, /* CSPCM_MM_23_READY: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 1 */
   0, /* CSPCM_MM_24_RAMPOUT: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 1 */
   0, /* CSPCM_MM_25_ACTIVE: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 1 */
   0 /* CSPCM_MM_26_HOLD: LSB: 2^0 OFF: 0 MIN/MAX: 0 .. 1 */
}; /* Description: Structure containing bitfields for Stateflow chart  */

/* Custom code: SPCM_MSPCS_ModMgr_tl/IncludeAppHeader/CC_AppHeaderInclude << declaration code >> */
#include "Rte_SteerPosnCtrlrManagerSwc.h"
/*----------------------------------------------------------------------------*\
  PARAMETERIZED MACROS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION PROTOTYPES
\*----------------------------------------------------------------------------*/

/******************************************************************************\
   StaticSFEntry: Default function class for static stateflow entry functions
\******************************************************************************/
static void CSPCM_MM_22_CLOSED_en(void);

static void CSPCM_MM_24_RAMPOUT_en(void);

/*----------------------------------------------------------------------------*\
  INLINE FUNCTIONS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION DEFINITIONS
\*----------------------------------------------------------------------------*/

/**************************************************************************************************\
 ***  FUNCTION:
 ***      SPCM_MSPCS_ModMgr
 *** 
 ***  DESCRIPTION:
 ***      
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***      tArbitrationState  SpcArbnSt           
 ***      tLateralControlModeRequestLatCtrlModReq       
 ***      float32            SpcActvnGain        
 ***      boolean            ErrMod              
 ***      Nm                 ColTqVal            
 ***      Degrees            SteerPosnLowrVal    
 ***      Degrees            ActAgLim            
 ***      float32            PaBlndGain          
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***
\**************************************************************************************************/
void SPCM_MSPCS_ModMgr(tArbitrationState SpcArbnSt, tLateralControlModeRequest LatCtrlModReq,
  float32 SpcActvnGain, boolean ErrMod, Nm ColTqVal, Degrees SteerPosnLowrVal, Degrees ActAgLim,
  float32 PaBlndGain)
{
   /* SLLocal: Default storage class for local variables | Width: 32 */
   float32 SSPCM_MM_213_Switch;
   float32 SSPCM_MM_29_Switch;

   /* SLLocal: Default storage class for local variables | Width: 8 */
   boolean SSPCM_MM_27_Relational_Operator;

   /* SLStaticLocalInit: Default storage class for static local variables with initvalue | Width: 32
    */
   static ms X_SSPCM_MM_210_Unit_Delay = 0;
   static ms X_SSPCM_MM_211_Unit_Delay = 0;
   static ms X_SSPCM_MM_212_Unit_Delay = 0;
   static Float32 X_SSPCM_MM_25_Unit_Delay = 0.F;

   /* SLStaticLocalInit: Default storage class for static local variables with initvalue | Width: 8
    */
   static boolean X_SSPCM_MM_210_Unit_Delay1 = 0; /* Description: ED4I_AVOID_TRANSFORM_VAR */
   static boolean X_SSPCM_MM_211_Unit_Delay1 = 0; /* Description: ED4I_AVOID_TRANSFORM_VAR */
   static boolean X_SSPCM_MM_212_Unit_Delay1 = 0; /* Description: ED4I_AVOID_TRANSFORM_VAR */

   /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/ZFDivA_fabs/Switch
      SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/ZFDivA_fabs/Switch: Omitted comparis
      on with constant.
      # combined # Relational: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/ZFDivA_fabs
      /Relational Operator */
   if (ColTqVal < 0.F) {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/ZFDivA_fabs/Switch
         # combined # Gain: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/ZFDivA_fabs/Ga
         in */
      SSPCM_MM_213_Switch = ColTqVal * -1.F;
   }
   else {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/ZFDivA_fabs/Switch */
      SSPCM_MM_213_Switch = ColTqVal;
   }

   /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Switch2
      SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Switch2: Omitted comparison 
      with constant.
      # combined # Relational: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Relational 
      Operator3 */
   if (SSPCM_MM_213_Switch > Rte_CData_DRVR_TQ_MAX_ALLWD_LOW()) {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Switch1
         SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Switch1: Omitted comparis
         on with constant. */
      if (!(X_SSPCM_MM_210_Unit_Delay1)) {
         /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Switch1
            # combined # Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/S
            witch2
            # combined # Sum: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Sum
            # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Count
            er/Unit Delay */
         X_SSPCM_MM_210_Unit_Delay = X_SSPCM_MM_210_Unit_Delay + SPCM_SAMPLE_TI;
      }
   }
   else {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Switch2
         # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/
         Unit Delay */
      X_SSPCM_MM_210_Unit_Delay = 0;
   }

   /* Relational: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Relational Opera
      tor
      # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Uni
      t Delay1
      # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Uni
      t Delay */
   X_SSPCM_MM_210_Unit_Delay1 = X_SSPCM_MM_210_Unit_Delay > Rte_CData_DRVR_TQ_MAX_FIL_TI_LOW();

   /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Switch2
      SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Switch2: Omitted comparison
       with constant.
      # combined # Relational: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Relational 
      Operator1 */
   if (SSPCM_MM_213_Switch > Rte_CData_DRVR_TQ_MAX_ALLWD_MID()) {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Switch1
         SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Switch1: Omitted compari
         son with constant. */
      if (!(X_SSPCM_MM_211_Unit_Delay1)) {
         /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Switch1
            # combined # Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/
            Switch2
            # combined # Sum: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Sum
            # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Count
            er1/Unit Delay */
         X_SSPCM_MM_211_Unit_Delay = X_SSPCM_MM_211_Unit_Delay + SPCM_SAMPLE_TI;
      }
   }
   else {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Switch2
         # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1
         /Unit Delay */
      X_SSPCM_MM_211_Unit_Delay = 0;
   }

   /* Relational: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Relational Oper
      ator
      # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Un
      it Delay1
      # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Un
      it Delay */
   X_SSPCM_MM_211_Unit_Delay1 = X_SSPCM_MM_211_Unit_Delay > Rte_CData_DRVR_TQ_MAX_FIL_TI_MID();

   /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Switch2
      SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Switch2: Omitted comparison
       with constant.
      # combined # Relational: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Relational 
      Operator2 */
   if (SSPCM_MM_213_Switch > Rte_CData_DRVR_TQ_MAX_ALLWD_HIGH()) {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Switch1
         SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Switch1: Omitted compari
         son with constant. */
      if (!(X_SSPCM_MM_212_Unit_Delay1)) {
         /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Switch1
            # combined # Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/
            Switch2
            # combined # Sum: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Sum
            # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Count
            er2/Unit Delay */
         X_SSPCM_MM_212_Unit_Delay = X_SSPCM_MM_212_Unit_Delay + SPCM_SAMPLE_TI;
      }
   }
   else {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Switch2
         # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2
         /Unit Delay */
      X_SSPCM_MM_212_Unit_Delay = 0;
   }

   /* Relational: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Relational Oper
      ator
      # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Un
      it Delay1
      # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Un
      it Delay */
   X_SSPCM_MM_212_Unit_Delay1 = X_SSPCM_MM_212_Unit_Delay > Rte_CData_DRVR_TQ_MAX_FIL_TI_HIGH();

   /* Logical: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Logical Operator
      # combined # TargetLink outport: SPCM_MSPCS_ModMgr_tl/DrvrTakeOvDetd
      # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter2/Un
      it Delay1
      # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter1/Un
      it Delay1
      # combined # Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColumnTorqueChecks/Counter/Uni
      t Delay1 */
   var_SPCM_MSPCS_ModMgr.DrvrTakeOvDetd = X_SSPCM_MM_210_Unit_Delay1 || X_SSPCM_MM_211_Unit_Delay1
    || X_SSPCM_MM_212_Unit_Delay1;

   /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColAbsPosnCheck/ZFDivA_fabs/Switch
      SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColAbsPosnCheck/ZFDivA_fabs/Switch: Omitted comparison 
      with constant.
      # combined # Relational: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColAbsPosnCheck/ZFDivA_fabs/Re
      lational Operator */
   if (SteerPosnLowrVal < 0.F) {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColAbsPosnCheck/ZFDivA_fabs/Switch
         # combined # Gain: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColAbsPosnCheck/ZFDivA_fabs/Gain
       */
      SSPCM_MM_29_Switch = SteerPosnLowrVal * -1.F;
   }
   else {
      /* Switch: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColAbsPosnCheck/ZFDivA_fabs/Switch */
      SSPCM_MM_29_Switch = SteerPosnLowrVal;
   }

   /* Relational: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/ColAbsPosnCheck/Relational Operator */
   SSPCM_MM_27_Relational_Operator = SSPCM_MM_29_Switch > ActAgLim;

   /* Begin execution of chart SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine */
   if (SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_22_CLOSED) {
      /* Begin execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.CLOSED */

      /* # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/LatCtrlModReq
         # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/LatCtrlModReq
         # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/LatCtrlModReq
         # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/LatCtrlModReq
         # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/LatCtrlModReq
         # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/PaBlndGain
         # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/SpcArbnSt
         # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/ErrMod
         # combined # TargetLink outport: SPCM_MSPCS_ModMgr_tl/DrvrTakeOvDetd */
      if (((LatCtrlModReq == TRFC_JAM_ASSI) || (LatCtrlModReq == EMGY_LANE_KEEP_AID_FOR_OBJ_RE) ||
       (LatCtrlModReq == EMGY_LANE_KEEP_AID_FOR_STAT) || (LatCtrlModReq == SFTY_LANE_KEEP_AID) ||
       (LatCtrlModReq == STEER_ASSC)) && (PaBlndGain <= SPCM_FLOAT_ZERO) && (SpcArbnSt == ARB_READY)
        && (ErrMod == FALSE) && (X_SSPCM_MM_25_Unit_Delay <= SPCM_FLOAT_ZERO) &&
       (var_SPCM_MSPCS_ModMgr.DrvrTakeOvDetd == FALSE) && (SSPCM_MM_27_Relational_Operator ==
       FALSE)) {
         /* State transition from SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.CLOSED to S
            PCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.READY */
         SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_22_CLOSED = 0;
         SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_23_READY = 1;
         CSPCM_MM_21_LatCtrlModCfmd_SPC = NO_LAT_REQ;

         /* # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/LatCtrlModReq */
         CSPCM_MM_21_TargetControlMode_SPC = LatCtrlModReq;
         DD_CSPCM_MM_21_SpcArbActvnReq = ARB_REQ_ACT;
         DD_CSPCM_MM_21_SpcCtrlrSt = SPC_READY;
      }

      /* End execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.CLOSED */
   }
   else {
      if (SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_23_READY) {
         /* Begin execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.READY */

         /* # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/LatCtrlModReq
            # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/SpcArbnSt
            # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/SpcArbnSt
            # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/ErrMod
            # combined # TargetLink outport: SPCM_MSPCS_ModMgr_tl/DrvrTakeOvDetd */
         if ((CSPCM_MM_21_TargetControlMode_SPC != LatCtrlModReq) || (SpcArbnSt == ARB_PASSIVE) ||
          (SpcArbnSt == ARB_LOCKED) || (ErrMod == TRUE) || (var_SPCM_MSPCS_ModMgr.DrvrTakeOvDetd ==
          TRUE) || (SSPCM_MM_27_Relational_Operator == TRUE)) {
            /* State transition from SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.READY to
                SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.CLOSED */
            SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_23_READY = 0;
            CSPCM_MM_22_CLOSED_en();
         }
         else {
            /* # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/SpcArbnSt */
            if (SpcArbnSt == ARB_ACTIVE) {
               /* State transition from SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.READY
                   to SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.ACTIVE */
               SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_23_READY = 0;
               SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_25_ACTIVE = 1;
               CSPCM_MM_21_LatCtrlModCfmd_SPC = CSPCM_MM_21_TargetControlMode_SPC;
               DD_CSPCM_MM_21_SpcArbActvnReq = ARB_REQ_ACT;
               DD_CSPCM_MM_21_SpcApplyingTq = TRUE;
               DD_CSPCM_MM_21_SpcCtrlrSt = SPC_ACTIVE;
            }
         }

         /* End execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.READY */
      }
      else {
         if (SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_24_RAMPOUT) {
            /* Begin execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.RAMPO
               UT */

            /* (Overlaytorque_SPC<=SPCM_FLOAT_ZERO)||...
               # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/SpcArbnSt
               # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/SpcArbnSt */
            if ((X_SSPCM_MM_25_Unit_Delay <= SPCM_FLOAT_ZERO) || (CSPCM_MM_21_ramping_tmr >
             Rte_CData_RAMPING_TMR_THD()) || ((SpcArbnSt != ARB_ACTIVE) && (SpcArbnSt !=
             ARB_PASSIVE))) {
               /* State transition from SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.RAMPO
                  UT to SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.CLOSED */
               SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_24_RAMPOUT = 0;
               CSPCM_MM_22_CLOSED_en();
            }
            else {
               CSPCM_MM_21_ramping_tmr = CSPCM_MM_21_ramping_tmr + SPCM_SAMPLE_TI;
            }

            /* End execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.RAMPOUT
             */
         }
         else {
            /* SFStaticLocalInit: Default storage class for static local variables with initvalue | 
               Width: 32 */
            static uint32 CSPCM_MM_21_hold_tmr = 0;

            if (SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_25_ACTIVE) {
               /* Begin execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.AC
                  TIVE */

               /* # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/SpcArbnSt
                  # combined # TargetLink outport: SPCM_MSPCS_ModMgr_tl/DrvrTakeOvDetd */
               if ((SpcArbnSt != ARB_ACTIVE) || (var_SPCM_MSPCS_ModMgr.DrvrTakeOvDetd == TRUE) ||
                (SSPCM_MM_27_Relational_Operator == TRUE)) {
                  /* State transition from SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.AC
                     TIVE to SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.RAMPOUT */
                  SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_25_ACTIVE = 0;
                  CSPCM_MM_24_RAMPOUT_en();
               }
               else {
                  /* # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/LatCtrl
                     ModReq
                     # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/ErrMod
                   */
                  if ((CSPCM_MM_21_TargetControlMode_SPC != LatCtrlModReq) || (ErrMod == TRUE)) {
                     /* State transition from SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine
                        .ACTIVE to SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.HOLD */
                     SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_25_ACTIVE = 0;
                     SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_26_HOLD = 1;
                     CSPCM_MM_21_TargetControlMode_SPC = NO_LAT_REQ;
                     DD_CSPCM_MM_21_SpcApplyingTq = TRUE;
                     CSPCM_MM_21_LatCtrlModCfmd_SPC = NO_LAT_REQ;
                     DD_CSPCM_MM_21_SpcCtrlrSt = SPC_HOLD;
                     CSPCM_MM_21_hold_tmr = 0;
                  }
               }

               /* End execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.ACTI
                  VE */
            }
            else {
               if (SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_26_HOLD) {
                  /* Begin execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine
                     .HOLD */

                  /* # combined # update of variable(s) associated with SPCM_MSPCS_ModMgr_tl/SpcArbn
                     St
                     # combined # TargetLink outport: SPCM_MSPCS_ModMgr_tl/DrvrTakeOvDetd */
                  if ((CSPCM_MM_21_hold_tmr > Rte_CData_HOLD_TMR_THD()) || (SpcArbnSt != ARB_ACTIVE)
                    || (var_SPCM_MSPCS_ModMgr.DrvrTakeOvDetd == TRUE) ||
                   (SSPCM_MM_27_Relational_Operator == TRUE)) {
                     /* State transition from SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine
                        .HOLD to SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.RAMPOUT */
                     SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_26_HOLD = 0;
                     CSPCM_MM_24_RAMPOUT_en();
                  }
                  else {
                     CSPCM_MM_21_hold_tmr = CSPCM_MM_21_hold_tmr + SPCM_SAMPLE_TI;
                  }

                  /* End execution of state SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.H
                     OLD */
               }
               else {
                  /* State transition to SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.CLOS
                     ED */
                  CSPCM_MM_22_CLOSED_en();
               }
            }
         }
      }
   }

   /* End execution of chart SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine */

   /* Unit delay: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/Unit Delay */
   X_SSPCM_MM_25_Unit_Delay = SpcActvnGain;

   /* TargetLink outport: SPCM_MSPCS_ModMgr_tl/LatCtrlModCfmdSPC */
   var_SPCM_MSPCS_ModMgr.LatCtrlModCfmdSPC = CSPCM_MM_21_LatCtrlModCfmd_SPC;

   /* TargetLink outport: SPCM_MSPCS_ModMgr_tl/SpcCtrlrSt */
   var_SPCM_MSPCS_ModMgr.SpcCtrlrSt = DD_CSPCM_MM_21_SpcCtrlrSt;

   /* TargetLink outport: SPCM_MSPCS_ModMgr_tl/SpcArbActvnReq */
   var_SPCM_MSPCS_ModMgr.SpcArbActvnReq = DD_CSPCM_MM_21_SpcArbActvnReq;

   /* TargetLink outport: SPCM_MSPCS_ModMgr_tl/SpcApplyingTq */
   var_SPCM_MSPCS_ModMgr.SpcApplyingTq = DD_CSPCM_MM_21_SpcApplyingTq;
}

/*----------------------------------------------------------------------------*\
  MODULE LOCAL FUNCTION DEFINITIONS
\*----------------------------------------------------------------------------*/

/**************************************************************************************************\
 ***  FUNCTION:
 ***      CSPCM_MM_22_CLOSED_en
 *** 
 ***  DESCRIPTION:
 ***      Entry function of state: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.CLOSED
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***
\**************************************************************************************************/
static void CSPCM_MM_22_CLOSED_en(void)
{
   SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_22_CLOSED = 1;
   CSPCM_MM_21_LatCtrlModCfmd_SPC = NO_LAT_REQ;
   CSPCM_MM_21_TargetControlMode_SPC = NO_LAT_REQ;
   DD_CSPCM_MM_21_SpcArbActvnReq = ARB_PASSIVE;
   DD_CSPCM_MM_21_SpcApplyingTq = FALSE;
   DD_CSPCM_MM_21_SpcCtrlrSt = SPC_CLOSED;
}

/**************************************************************************************************\
 ***  FUNCTION:
 ***      CSPCM_MM_24_RAMPOUT_en
 *** 
 ***  DESCRIPTION:
 ***      Entry function of state: SPCM_MSPCS_ModMgr_tl/SPCM_MSPCS_ModMgr/SpcStateMachine.RAMPOUT
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***
\**************************************************************************************************/
static void CSPCM_MM_24_RAMPOUT_en(void)
{
   SIBFS_SpcStateMachine_SPCM_MM_2.CSPCM_MM_24_RAMPOUT = 1;
   CSPCM_MM_21_TargetControlMode_SPC = NO_LAT_REQ;
   DD_CSPCM_MM_21_SpcArbActvnReq = ARB_RAMP_OUT;
   DD_CSPCM_MM_21_SpcApplyingTq = TRUE;
   CSPCM_MM_21_LatCtrlModCfmd_SPC = NO_LAT_REQ;
   DD_CSPCM_MM_21_SpcCtrlrSt = SPC_RAMPOUT;
   CSPCM_MM_21_ramping_tmr = 0;
}

#endif /* SPCM_MSPCS_MODMGR_C */
/*----------------------------------------------------------------------------*\
  END OF FILE
\*----------------------------------------------------------------------------*/
